//
//  SAPPriceCollectionViewCell.m
//  CarsHome
//
//  Created by dapeng on 15/12/2.
//  Copyright © 2015年 dapeng. All rights reserved.
//

#import "SAPPriceCollectionViewCell.h"

@implementation SAPPriceCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        
        _HUD = [MBProgressHUD showHUDAddedTo:self animated:YES];
        _HUD.color = [UIColor blackColor];
        _HUD.dimBackground = YES;
        _HUD.labelText = @"正在加载";

        [SAPNetWorkTool getWithUrl:price parameter:nil httpHeader:nil responseType: ResponseTypeJSON success:^(id result) {
            NSDictionary *dic = result[@"result"];
            self.oneModel = [[SAPpriceOneModel alloc] initWithDataSource:dic];
            _HUD.hidden = YES;
            dispatch_async(dispatch_get_main_queue(), ^{
                [self.tableView reloadData];
            });
        } fail:^(NSError *error) {
            NSLog(@"请求失败");
        }];
        
    }return self;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
    SAPpriceTwoModel *twoModel = self.oneModel.newslistArray[indexPath.row];
    
    NSString *str = [NSString stringWithFormat:@"http://cont.app.autohome.com.cn/autov4.2.5/content/News/newscontent-a2-pm1-v4.2.5-n%@-lz0-sp0-nt0-sa1-p0-c1-fs0-cw320.html", twoModel.id];
   [self.delegate passBaseValue:str];
}


@end
